<?php
namespace app\api\controller;

class Feedback
{
    public $pagesize=5;

    /**
     * 获取用户信息
     * @param unknown $uid
     * @return Ambigous <multitype:, mixed>
     */
    public function _getUserInfo($uid,$field='*')
    {
        $userinfo =getUserInfoForID($uid,$field);
        return $userinfo;
    }
    
    
    /**
     * 教师申请接口
     *  http://127.0.0.1:9094/api/feedback/apply?uid=95&conts=你好
     * @return \think\response\Json
     */
    public function feedback()
    {

        $auth = trim(input("request.auth"));//用户auth
        $userInfo = checkLoginExp($auth);
        if (empty($userInfo)) {
            $return = ['err' => 1, 'msg' => '操作失败', 'devMsg' => '操作失败，参数错误[auth]'];
            return json($return);
        }
        $uid=$userInfo['id'];
        $nickname =$userInfo['nickname'];//用户ID
        $phone =$userInfo['uname'];//用户ID
        $conts =trim(input("conts"));

        $FeedbackModel = new \app\admin\model\Feedback();

        $data=array(
            'uid'=>$uid,
            'name'=>$nickname,
            'tel'=>$phone,
            'conts'=>$conts,
            'ctime'=>date("Y-m-d H:i:s"),
        );
        $insertId =$FeedbackModel->add($data);
        if($insertId)
        {

            $return = ['err'=>0,'msg'=>'操作成功','data'=>$data,'devMsg'=>'操作成功'];
            return json($return);
            
        }else 
        {
            $return = ['err'=>10,'msg'=>'操作失败','devMsg'=>''];
            return json($return);
        }
    }
    
    public function addFangFriend($uid,$fuid)
    {
         
        $userModel=new \app\admin\model\Friend();
        $old=$userModel->getDataForWhere(array('uid'=>$uid,'fuid'=>$fuid));
        if(empty($old))
        {
            $insertId = $userModel->add(array('uid'=>$uid,'fuid'=>$fuid,'ctime'=>date('Y-m-d H:i:s')));
        }
    }
   public function addFangKe($insertData)
   {
       
       $userModel=new \app\admin\model\User();
       $insertId = $userModel->add($insertData);
       return $insertId;
   }
   public function editFangKe($update,$w)
   {
        
       $userModel=new \app\admin\model\User();
       $userModel->updateDataForWhere($update,$w);
 
   }
   
   
}
